Skip to content

fix(antigravity-direct): carry tool_call ids on history parts for Claude targets (opencode#1550) - #5125

Merged
dezren39 merged 1 commit into
mainfrom
fix/1550-claude-tool-use-id
Nov 3, 2026
Merged

dezren39 merged 1 commit into
mainfrom
fix/1550-claude-tool-use-id

Conversation

@dezren39

@dezren39 dezren39 commented Nov 3, 2026 •

Copy link
Copy Markdown
Member

Part 2 of the opencode#1550 fix (the schema half was #5110)

Live verification of #5110 caught a second, distinct Claude-leaf 400 in the route ledger minutes after deploy: a workhorse session succeeded on the leaf at 20:20:02Z, then its next step 400'd at 20:20:18Z with a different Anthropic error:

messages.1.content.0.tool_use.id: Field required

Root cause (reproduced + probed live)

Any request whose history contains an assistant tool call 400s on the Claude leaf. The door converted OpenAI tool calls to v1internal functionCall parts with no id (Gemini pairs calls by name/order and never needed one). For Claude models the upstream's v1internal→Anthropic conversion emits one tool_use block per functionCall part — with no id — and Anthropic rejects it. Adding the id to functionCall moved the error to the result side (tool_result.tool_use_id: Field required), confirming the proto's id field on both part kinds is the interop channel.

Probed against a scratch instance of this door on the real upstream before merging: history with a single call, parallel calls, two full tool rounds, and streaming — all 400 before, all 200 after. First turns were never affected; every continuation was.

Fix

For Claude targets only (anthropic flag from part 1):

  • history functionCall parts carry the client's tool_call id; functionResponse parts carry the matching tool_call_id.
  • Response side: an upstream-provided call id is kept when one arrives (Anthropic mints tool_use ids; replaying the same id keeps the round trip consistent) — the door's minted call_<uuid> shape remains the fallback.

Gemini payloads are byte-identical to before (ids stay off that path).

Tests

node --test bin/antigravity-direct.test.mjs — 21/21 (19 + 2 new, same stub-upstream harness): Claude history reaches upstream with matching ids on both part kinds; Gemini history stays id-less.

The fork twin lands in developing-today/opencode under the same issue.


Autofix with [code]smith
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

@dezren39
dezren39 requested a review from a team as a code owner November 3, 2026 20:29
@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Nov 3, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-11-03T20:31:12.815098Z 6972806 PR opened
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant